package net.pimpas.web.jsf.components.accordionpanel;

import javax.faces.component.UIComponent;

import net.pimpas.web.jsf.components.UIComponentPimpasBaseTag;

public class UIAccordionPanelTag extends UIComponentPimpasBaseTag {
	
	private String title;
	private String icon;
	private String state;
	private String componentPath;
	
	@Override
	protected void setProperties(UIComponent component) {
		UIAccordionPanel panel = (UIAccordionPanel) component;
		
		if(this.getTitle() == null || this.getTitle().equals(""))
			this.setTitle("none");
		if(this.getIcon() == null || this.getIcon().equals(""))
			this.setIcon(UIAccordionPanel.DEFAULT_ICON);
		if(this.getState() == null || this.getState().equals(""))
			this.setState(UIAccordionPanel.COLAPSED_STATE);
		this.setState(this.getState().toUpperCase());
		if(!this.getState().toUpperCase().equals(UIAccordionPanel.EXPANDED_STATE))
			this.setState(UIAccordionPanel.COLAPSED_STATE);
		if(this.getComponentPath() == null || this.getComponentPath().equals(""))
			this.setComponentPath(UIAccordionPanel.DEFAULT_COMPONENT_PATH);
		
		panel.setTitle(this.getTitle());
		panel.setIcon(this.getIcon());
		panel.setState(this.getState());
		panel.setComponentPath(this.getComponentPath());
		
		super.setProperties(component);
	}

	@Override
	public String getComponentType() {
		return UIAccordionPanel.COMPONENT_TYPE;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getComponentPath() {
		return componentPath;
	}

	public void setComponentPath(String componentPath) {
		this.componentPath = componentPath;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}
}